<template>
<div>
  <van-sticky>
    <van-nav-bar
      title="下单页"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
  </van-sticky>
  <div>
    <van-row class="addr">
      <van-col span="22" class="address">
        <div>
          联系人：<span>{{defaultAddress.consignee}}</span>
        </div>
        <div>
          电话：<span>{{defaultAddress.phone}}</span>
        </div>
        <div>
          地址：<span>{{defaultAddress.address}}</span>
        </div>
        <van-divider />
      </van-col>
      <van-col span="2" class="arrow"><van-icon name="arrow" size="19"/></van-col>
    </van-row>
  </div>


</div>
</template>

<script>
export default {
  name: "buy",
  data(){
    return{
      defaultAddress:'',
      addressList:[],
      hasAddress:false,
      storeId:0
    }
  },
  methods:{

    queryAddress(){
      let _this = this
      this.$axios.get("/address/queryAddress").then(resp => {
        console.log(resp)
        if (resp.data.result) {
          _this.addressList = resp.data.data.addressList
          console.log(resp.data.data.addressList)
          let address
          for (address of _this.addressList){
            console.log(address)
            if (address.isDefault==1){
              _this.defaultAddress = address
              _this.defaultAddress.address = address.provinceName+address.cityName+address.districtName+address.detail

              _this.hasAddress = true
            }
          }
        }
      })
    },
    onClickLeft() {
      this.$router.back()
    },
    onEdit(){
      alert("跳转地址编辑页面")
    },

  },
  created() {
    this.storeId = this.$route.params.storeId
    this.queryAddress()
  }


}
</script>

<style scoped>
.addr{
  padding: .3rem;
  color: #646566;
}
.address{
  font-size: .2rem;
}
.arrow{
  line-height: 1rem;
}

.address div{
  margin-bottom: .2rem;
}
</style>
